<%@ page language="java" %>

<%@ page import="java.util.List,
                java.util.ArrayList,
                java.util.HashMap,
                com.scalar.chiptrack.commons.Constants,
                com.scalar.chiptrack.users.User,
                com.scalar.chiptrack.users.Functionality,
                com.scalar.chiptrack.commons.SessionKeys,
                com.scalar.chiptrack.sales.LineItem,
                com.scalar.chiptrack.sales.dao.SalesOrderDAO,
                com.scalar.chiptrack.operations.packingslip.CustomerShippingLineItem,
                com.scalar.chiptrack.operations.packingslip.forms.PackingSlipForm,
                com.scalar.chiptrack.utils.ConfigManager,
                com.scalar.chiptrack.utils.StringUtils"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/packingSlipMenu.do"/>

<html:html locale="true">

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<!--Bhaskar added this scriptlet on 16 july 2003-->
<% User user1 = (User)session.getAttribute (SessionKeys.USER_KEY); %>
<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">

<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</SCRIPT>
<SCRIPT language="JavaScript">
function openInventory (mktPartNumber, lineItemId, fieldName, fieldName1, csLineItemId, quantityToBeShipped)
{
    var finalInventoryURL = '<%=chipTracContext%>/finalInventory.do?mktPartNumber=' + mktPartNumber + '&lineItemId=' + lineItemId + '&fieldName=' + fieldName + '&fieldName1=' + fieldName1 + '&csLineItemId=' + csLineItemId + '&quantityToBeShipped='+quantityToBeShipped + '&viewonly=true';
    newWindow = window.open (finalInventoryURL,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=900,height=450,resizable=yes');
    newWindow.focus();
}

function updatePackingSlip() 
{
	var errors = '';
	if( document.packingSlipForm.tracking.length == null) 
	{
		if( document.packingSlipForm.tracking.value.trim().length == 0 )
		{
			errors = "<li> Freight Tracking No can neither be blank nor contain blank spaces";		 
			document.packingSlipForm.tracking.value = "";
			document.packingSlipForm.tracking.focus();
		}
		else if( alphanumSpecial( document.packingSlipForm.tracking.value.trim(), "Freight Tracking No", "Y" ) == false )
		{	
			errors = errMsg ;		 
			document.packingSlipForm.tracking.value = "";
			document.packingSlipForm.tracking.focus();
		}
		else
		{
			document.packingSlipForm.tracking.value = document.packingSlipForm.tracking.value.trim();
		}
	}
	else
	{
		var mandatoryFlag = "N";
		for( x=0; x < document.packingSlipForm.tracking.length; x++ )
		{
			if( x == 0 )
			{
				mandatoryFlag = "Y";
			}
			else
			{
				mandatoryFlag = "N";
			}
			if( document.packingSlipForm.tracking[x].value.trim().length == 0 && mandatoryFlag == "Y")
			{
				errors ="<li> Freight Tracking No can neither be blank nor contain blank spaces";	 
				document.packingSlipForm.tracking[x].value = "";
				document.packingSlipForm.tracking[x].focus();
			}
			else if( alphanumSpecial(document.packingSlipForm.tracking[x].value.trim(),"Freight Tracking No", mandatoryFlag)==false )
			{	
				errors = errMsg ;		 
				document.packingSlipForm.tracking[x].value = "";
				document.packingSlipForm.tracking[x].focus();
			}
			else
			{
				document.packingSlipForm.tracking[x].value = document.packingSlipForm.tracking[x].value.trim();
			}
		}
	}

	if(errors != '')
	{
		var pa=document.getElementById("errors");
		pa.innerHTML = errors;
		return;
	}

    document.packingSlipForm.action = "<%=chipTracContext%>/packingSlip.do?action=updateInvNoAndAirwayBillNo";
    document.packingSlipForm.submit();
}

function printablePackingSlip(customerShippingId) 
{
    var packingSlipViewURL = '<%=chipTracContext%>/packingSlip.do?action=printView&showMainMenu=false&customerShippingId=' + customerShippingId
    newWindow = window.open (packingSlipViewURL,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,resizable=yes');
    newWindow.focus();
}

function cancelAndGoBack() 
{
    document.packingSlipForm.action = "<%=chipTracContext%>/searchPackingSlip.do";
    document.packingSlipForm.submit();
}

function sendMail( salesOrderId, customerShippingId )
{    
    newWindow = window.open ('<%=chipTracContext%>/sendMail.do?salesOrderId=' + salesOrderId + '&customerShippingId=' + customerShippingId,'sendMailPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=800,height=550,resizable=yes');
    newWindow.focus();
}

function showCommercialInvoice( salesOrderId, customerShippingId, locationId )
{  
    var invoiceURL = '<%=chipTracContext%>/commercialInvoice.do?action=showInvoice&salesOrderId=' + salesOrderId + '&customerShippingId=' + customerShippingId + '&locationId=' + locationId;
    newWindow = window.open (invoiceURL,'showCommercialInvoice','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,resizable=yes');
    newWindow.focus();
}

function addTrackingNumberField( fontId ) 
{
    var htmltext1 = '<table style=NArialL cellspacing=0 cellpadding=0 width="100%" border=0><tr><td width="22%"><font class="NArialL"><font color=green>Freight Tracking No:</font></font></td><td width="21%">&nbsp;&nbsp;<input type=text name="tracking" class=txfield size="20" maxlength="50" /></td><td colspan=4>&nbsp;</td></tr></table>';
    var pa1 = document.getElementById (fontId);
    pa1.insertAdjacentHTML ('BeforeEnd',htmltext1);
}

function showErrorReportPage()
{
    newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
    newWindow.focus();
}

</SCRIPT>


<!-- Top Header Start-->
<%@include file="/jsp/includes/header.jsp"  %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@include file="/jsp/operations/operations_menu.jsp" %>
<!-- end of the side navigations -->


<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>

<%
    String salesOrderIdFromRequest = request.getParameter ("salesOrderId");
    if (salesOrderIdFromRequest == null) {
        salesOrderIdFromRequest = "-1";
    }
%>


<!-- body starts -->

<table border='0' align='center' width='98%'>
<tr><td align='center' valign='center' width='80%'><font class="NArialW">&nbsp;&nbsp;Packing Slip</font>

<%
        PackingSlipForm packingSlipForm = (PackingSlipForm) request.getAttribute ("packingSlipForm");
        int customerShippingId = packingSlipForm.getCustomerShippingId();
        int salesOrderId = packingSlipForm.getSalesOrderId();
%>
        <br><font align=right class="NArialS"><a href="javascript:sendMail( <%=salesOrderId%>, <%=customerShippingId%> );" title='Click here to send mail'><b>[E-mail this Packing Slip]</b></a>&nbsp;&nbsp;
        &nbsp;&nbsp;<a href="javascript:printablePackingSlip(<%=customerShippingId%>);" onMouseOver="window.status='Printer-Friendly Version';return true" onMouseOut="window.status='';return true"><img src='<%=chipTracContext%>/jsp/includes/images/spacer.gif' border='0' height='1' width='1'><b>[Printer-Friendly Version]</b></a>&nbsp;&nbsp;
        <% if ( user1.isActionAllowed ( Functionality.COMMERCIAL_INVOICE,    User.USER_ACTION_VIEW ) ) { %>        
        &nbsp;&nbsp;<font class="NArialS"><a href="javascript:showCommercialInvoice( <%=salesOrderId%>, <%=customerShippingId%>, <%=packingSlipForm.getShippingFromLocationId()%>);" onMouseOver="window.status='Commercical Invoice';return true" onMouseOut="window.status='';return true"><img src='<%=chipTracContext%>/jsp/includes/images/spacer.gif' border='0' height='1' width='1'><b>[Commercial Invoice]</b></a>&nbsp;&nbsp;</font>
        <% } else { %>
        &nbsp;&nbsp;<font class="NArialS" color='blue'><b>[Commercial Invoice]</b>&nbsp;&nbsp;</font>
        <% } %>
        <!--&nbsp;&nbsp;<a href="javascript:showCommercialInvoice( <%=salesOrderId%>, <%=customerShippingId%>);" onMouseOver="window.status='Commercial Invoice';return true" onMouseOut="window.status='';return true"><img src='<%=chipTracContext%>/jsp/includes/images/spacer.gif' border='0' height='1' width='1'><b>[Commercial Invoice]</b></a>&nbsp;&nbsp;</font-->

    </td>
</tr>
</table>

<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>

<html:form name="packingSlipForm" type="com.scalar.chiptrack.operations.packingslip.forms.PackingSlipForm" action="/packingSlip.do?action=save">
<html:hidden name="packingSlipForm" property="customerShippingId"/>
<input type='hidden' name='autoConfirmPackingSlip' value='<%=request.getAttribute ("AUTO_CONFIRM_PACKING_SLIP")%>'/>

<chiptrack:errors styleClass="NArialL"/>

   <table border="0" width="90%" align=right class='NArialL'>
   <tr><td colspan=5 class="NArialL" align="left"><font color="FF0000"><FONT id="errors"></FONT></font></TD></TR>
   <tr><td>&nbsp;</td></tr>
   <!--Bhaskar added this scriptlet on  16 july 2003-->
	<% if ( !user1.isActionAllowed ( Functionality.PACKING_SLIP, User.USER_ACTION_MODIFY ) ) { %> 
            <TR><TD colspan='5'><font class='NArialL'><font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b>
            </font><TD><TR>  
        <% } %>
    
    <tr>
       <td width="21%"><font class="NArialL">PackingSlip Label:</font></td>
       <td width="21%">
                <html:text disabled="true" name="packingSlipForm"  property="label" size="20" maxlength="50" styleClass="disabledtxfield"/>
                <html:hidden name="packingSlipForm" property="label"/>
        
        <td width="3%">&nbsp;</td>
        <td colspan='3'>&nbsp;</td>
        </tr>


     <tr>
       <td width="21%"><font class="NArialL">Customer PO:</font></td>
       <td width="21%"><html:text disabled="true" name="packingSlipForm"  property="customerPO" size="20" styleClass="disabledtxfield"/>
       </td>       
        <td width="3%">&nbsp;</td>
        <td width="21%"><font class="NArialL">Sales Order No:</font></td>
       <td width="21%">
            <html:text disabled="true" name="packingSlipForm"  property="salesOrderNumber" size="20" styleClass="disabledtxfield"/>
            <html:hidden name="packingSlipForm" property="salesOrderNumber"/>
            <html:hidden name="packingSlipForm" property="salesOrderId"/>
       </td>
        <td width="3%">&nbsp;</td>
    </tr>

     <tr>

        <td width="21%"><font class="NArialL">Customer Name:</font></td>
        <td width="21%">
            <html:text disabled="true" name="packingSlipForm"  property="customerName" size="20" maxlength="50" styleClass="disabledtxfield"/>
            <html:hidden name="packingSlipForm" property="customerName"/>
            <html:hidden name="packingSlipForm" property="customerPO"/>
        </td>
        <td width="3%">&nbsp;</td>

       <td width="21%"><font class="NArialL">Shipping Contact Person:</font></td>
       <td width="21%">
            <html:text disabled="true" name="packingSlipForm"  property="contactPerson" size="20" maxlength="50" styleClass="txfield"/>
            
       </td>
       <td width="3%">&nbsp;</td>
    </tr>

    <tr>
       <td width="21%"><font class="NArialL">Regional Rep:</font></td>
       <td width="21%">
            <html:text disabled="true" name="packingSlipForm"  disabled="true" property="repOffice" size="20" maxlength="50" styleClass="disabledtxfield"/>
            <html:hidden name="packingSlipForm" property="repOffice"/>
       </td>
       <td width="3%">&nbsp;</td>

	   <td width="21%"><font class="NArialL">Weight:</font></td>
       <td width="21%">
            <html:text disabled="true" name="packingSlipForm"  property="weight" size="20" maxlength="50" styleClass="txfield"/>(Lbs)
            <html:hidden name="packingSlipForm" property="weight" />
       </td>
	   <td width="3%">&nbsp;</td>
     </tr>
     <tr>
	   <td width="21%"><font class="NArialL">Delivery Terms:</font></td>
       
        <td width="21%">
            
                    <html:text name="packingSlipForm"  property="fob" disabled="true" size="20" maxlength="50" styleClass="disabledtxfield"/>
                    <html:hidden name="packingSlipForm" property="fob" />
            
       </td>

       <td width="3%">&nbsp;</td>

	   <td width="21%"><font class="NArialL">No. Of Boxes:</font></td>
       <td width="21%">            
                <html:text disabled="true"  name="packingSlipForm" property="noOfBoxes" size="20" maxlength="10" styleClass="txfield"/>            
                <html:hidden name="packingSlipForm" property="noOfBoxes" />
       </td>
	   <td width="3%">&nbsp;</td>
     </tr>
     <tr>
        <td width="21%">
            <font class="NArialL">Freight Tracking No:</font>
        </td>
       <td width="21%" valign=center>
       <%
            String[] trackingNumbers = packingSlipForm.getTracking();

            String firstTrackingNumber = "";

            if( ( trackingNumbers != null ) && 
                ( trackingNumbers.length >= 1) && 
                ( trackingNumbers[0] != null ) && 
                ( trackingNumbers[0].trim().length() != 0 ) )
            {
                firstTrackingNumber = trackingNumbers[0];
            }
       %>

            <input type=text name="tracking" size="20" maxlength="50" class="txfield" value='<%=firstTrackingNumber%>' />
            <a href="javascript:addTrackingNumberField('font1');" title='Click here to add new Trackig Number'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align=center></a>
       </td>
       <td width="3%">&nbsp;</td>

	   <td width="21%"><font class="NArialL">Shipped VIA:</font></td>
       <td width="21%">
            <html:text disabled="true" name="packingSlipForm"  property="shippedVia" size="20" maxlength="50" styleClass="disabledtxfield"/>
            <html:hidden name="packingSlipForm" property="shippedVia" />
            <html:hidden name="packingSlipForm" property="shippingMethod" />
            <html:hidden name="packingSlipForm" property="shippingAccount" />
       </td>
	   <td width="3%">&nbsp;</td>
	 </tr>

    <!-- show all other tracking numbers -->
    <%
        if( ( trackingNumbers != null ) && ( trackingNumbers.length >= 2 ) )
        {
            for( int i = 1; i < trackingNumbers.length; i++ )
            {
    %>
                <tr><td colspan='6'>
                    <table style=NArialL cellspacing=0 cellpadding=0 width="100%" border=0>
                        <tr>
                            <td width="22%"><font class="NArialL">Freight Tracking No:</font></td>
                            <td width="21%">&nbsp;&nbsp;<input type=text name="tracking" class=txfield size="20" maxlength="50" value='<%=trackingNumbers[i]%>'/></td>
                            <td colspan=4>&nbsp;</td>
                        </tr>
                    </table>
                </td></tr>
    <%
            }
        }
    %>

    <!-- add tracking number fields -->
    <tr><td colspan='6'><font id="font1"></font></td></tr>


	 <tr>
	   <td width="21%"><font class="NArialL">Billing Address:</font></td>
	   <td width="21%">
                <html:textarea disabled="true" rows="5" name="packingSlipForm" property="billingAddress" cols="20" styleClass="disabledtxfield"/>
                <html:hidden name="packingSlipForm" property="billingAddress" />

           </td>
	   <td width="3%">&nbsp;</td>
       <td width="21%"><font class="NArialL">Shipping Address:</font></td>
       <td width="21%"><html:textarea disabled="true" rows="5" name="packingSlipForm" property="shippingAddress" cols="20" styleClass="disabledtxfield"/>
                       <html:hidden name="packingSlipForm" property="shippingAddress" /> 
                       <html:hidden name="packingSlipForm" property="shippingToAddressId" />
                       <html:hidden name="packingSlipForm" property="shippingFromAddressId" />
       </td>
       <td width="3%">&nbsp;</td>
	 </tr>


        <tr>
            <td width="21%"><font class="NArialL">Actual Ship Date (mm/dd/yyyy):</font></td>
            <td width="21%">
            <html:text disabled="true"  name="packingSlipForm"  property="shipDate" size="11" maxlength="10" styleClass="disabledtxfield"/>
            </td>
            <td width="3%">&nbsp;</td>
            <td width="21%" class="NArialL">Invoice #</td>
            <td width="21%"><html:text name="packingSlipForm" property="invNo" maxlength="50" styleClass="txfield"/></td>
	   <td width="3%">&nbsp;</td>
	 </tr>

        <tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>

	 <tr><td colspan=6>
	 	<font class="NArialL">Shipping Instructions:</font><br>
                        <html:textarea rows="4" name="packingSlipForm" disabled="true" property="shippingInstructions" cols="60" styleClass="disabledtxfield"/>
                        <html:hidden name="packingSlipForm" property="shippingInstructions" />
    	 	
	 </td></tr>
	 <tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
	 <tr><td colspan=6>
		<table border="0" width="98%" bordercolor="#FFFFFF">
	     <tr>
               <!--td width="4%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Select</font></td-->
	       <td width="4%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Line Item</font></td>
	       <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key = "label.mfgPartNumber" /></font></td>
	       <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key = "label.customerPartNumber" /></font></td>
	       <td width="25%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Description</font></td>
	       <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Unit Type</font></td>
	       <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Req. Ship Date</font></td>
	       <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Sch. Ship Date</font></td>
                <!--td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Ship Date</font></td-->
	       <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Requested Quantity</font></td>
               <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Quantity To be Shipped</font></td>
	       <td colspan='2' width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Quantity Shipped</font></td>
	       <!--td width="8%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Balance</font></td-->
               <td width="8%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Status</font></td>
	    </tr>

            <%
                
                List orderLineItemList = (List) request.getAttribute ("orderLineItemList");
                if (orderLineItemList == null) orderLineItemList = new ArrayList();

                HashMap csLineItemMap = (HashMap) request.getAttribute ("customerShippingLineItemMap");
                if (csLineItemMap == null) csLineItemMap = new HashMap();

                LineItem lineItem = null;
                CustomerShippingLineItem csLineItem = null;
                int size = orderLineItemList.size();

                String bgColor="#FFFFEE";

                HashMap qtyToBeShippedList = new HashMap();
                //for (int i=(size-1); i>=0; i--) {
                 for (int i=0; i <= (size-1); i++) { // changed by hareesh on 9th July 2003
                    if (bgColor.equalsIgnoreCase ("#FFFFEE")) bgColor = "#DEE1E2";
                    else if (bgColor.equalsIgnoreCase ("#DEE1E2")) bgColor = "#FFFFEE";

                    lineItem = (LineItem) orderLineItemList.get (i);
                    csLineItem = (CustomerShippingLineItem) csLineItemMap.get (lineItem.getLineItemId()+"");

                    //Added by vasu on 22 May 2003
                     String description = null;
                    
                    if( csLineItem != null )
                    {
                        description = csLineItem.getDescription();
                    }

                    // Balaram, June 23, 2003
                    if( ( ( description == null ) || ( description.trim().length() == 0 ) ) && ( lineItem != null ) )
                    {
                        description = lineItem.getDescription();
                    }

                    if( ( description == null ) || ( description.equals( "null" ) ) )
                    {
                        description = "";
                    }

                    //Added  by vasu for softwareVersion  on 22 May 2003    
                    String softwareVersion = null;
                    if(csLineItem != null) 
                    {
                        softwareVersion = csLineItem.getSoftwareVersion();
                    }
                    //if((softwareVersion == null) && (lineItem != null))
                    //softwareVersion = lineItem.getSoftwareVersion();
                    if((softwareVersion == null) || (softwareVersion != null) && (softwareVersion.equals("null")))
                    {
                        softwareVersion = "";
                    }
                    //Added  by Bhaskar for customerPartNumber  on 16 Dec 2003    
                    String customerPartNumber = null;
					String units = null;
                    if(csLineItem != null) 
                    {
                        customerPartNumber = csLineItem.getCustomerPartNumber();
						units = csLineItem.getUnits();
                    }
                    //if((softwareVersion == null) && (lineItem != null))
                    //softwareVersion = lineItem.getSoftwareVersion();
                    if((customerPartNumber == null) || ((customerPartNumber != null) && (customerPartNumber.equals("null"))))
                    {
                        customerPartNumber = "";
                    }
					if((units == null) || ((units != null) && (units.equals("null"))))
                    {
                        units = "";
                    }

            %>
                <tr>

                    <td width="4%" align="center" bgcolor='<%=bgColor%>'>
                        <font class="NArialL"><%=lineItem.getLineItemNo()%></font>
                        <input type="hidden" name='<%="id_"+i%>' value='<%if (csLineItem != null) out.print (csLineItem.getId());%>'>
                        <input type="hidden" name='<%="lineItemId_"+i%>' value='<%=lineItem.getLineItemId()%>'>
                        <input type="hidden" name='<%="lineItemNumber_"+i%>' value='<%=lineItem.getLineItemNo()%>'>
                    </td>
                    <td width="15%" align="center" bgcolor='<%=bgColor%>' nowrap>
                        <font class="NArialL"><%=lineItem.getManufacturingPartNo()%></font>
                                              <input type="hidden" name='<%="mktPartNumber_"+i%>' value="<%=lineItem.getManufacturingPartNo()%>">  
                    </td>
                    <td width="15%" align="center" bgcolor='<%=bgColor%>' nowrap>
                        <font class="NArialL"><%=customerPartNumber%></font>
                    </td>
                    <td width="240" align="center" bgcolor='<%=bgColor%>'>
                        <font class="NArialL"><textarea disabled name='<%="description_"+i%>' class="txfield" rows='3' cols='20'><%=description%></textarea></font>
                    </td>
                    <td width="15%" align="center" bgcolor='<%=bgColor%>' nowrap>
                        <!--
                        <font class="NArialL"><%=lineItem.getManufacturingPartNo()%></font>                        
                       -->
                        <input type="text" align='right' disabled name='<%="units_"+i%>' size="8" maxlength="50" class='txfield' value='<%=units%>'>
                    </td>
                    <td width="10%" align="right" bgcolor='<%=bgColor%>' nowrap>
                        <font class="NArialL"><%=lineItem.getRequestDate()%></font>
                    </td>
                    <td width="10%" align="right" bgcolor='<%=bgColor%>' nowrap>
                        <font class="NArialL"><%=lineItem.getScheduleDate()%></font>
                    </td>

                    <%
                        /*String shippedDate = null;
                        if (csLineItem != null) {
                            shippedDate = csLineItem.getShippedDate();
                        }
                        if ((shippedDate == null) || ("null".equalsIgnoreCase (shippedDate))) {
                            shippedDate = lineItem.getScheduleDate();
                        }*/
                    %>
                    <!--td width="10%" align="center" bgcolor='<%=bgColor%>'>
                        <font class="NArialL"><input type='text' name='shippedDate_"+i' size='8' class='txfield' value='shippedDate'></font>
                    </td-->
                    <td width="10%" align="right" bgcolor='<%=bgColor%>' nowrap>
                    <%
                        int requestedQuantity = lineItem.getQuantity();
                        int quantityToBeShipped = -1;

                        if (csLineItem != null) {
                            qtyToBeShippedList.put (i+"", csLineItem.getQtyToBeShipped()+"");
                            quantityToBeShipped = csLineItem.getQtyToBeShipped();
                        }
                        
                        //if ((!viewPackingSlip) && (quantityToBeShipped != -1)) 
                        if (quantityToBeShipped != -1) {
                            requestedQuantity = quantityToBeShipped;
                        }
                    %>
                        <font class="NArialL"><%=StringUtils.formatUnits(lineItem.getQuantity())%></font>
                                              <input type="hidden" name='<%="quantityRequested_"+i%>' value="<%=requestedQuantity%>">
                    </td>

                    <td width="10%" align="right" bgcolor='<%=bgColor%>'>
                        <font class="NArialL"><%if (csLineItem != null) out.print (StringUtils.formatUnits(csLineItem.getQtyToBeShipped())); else out.print (StringUtils.formatUnits(requestedQuantity));%>
                        <!--input type="text" name='<%="quantityToBeShipped_"+i%>' size="8" disabled class='disabledtxfield' value=''-->
                        </font>
                    </td>

                    <td width="12%" align=center bgcolor='<%=bgColor%>'>
                        <font class="NArialL">
                        <!--input type="text" name='<%="quantityShipped_"+i%>' size="8" <%if (((csLineItem != null) && (csLineItem.getStatus().equalsIgnoreCase (Constants.CUSTOMER_SHIPPING_STATUS_ISSED))) == false) out.print ("class='txfield'"); else out.print ("disabled class='disabledtxfield'");%>  value='<%if (csLineItem != null) out.print (csLineItem.getQtyShipped());%>'-->
                        <input type="hidden" name='<%="quantityShipped_"+i%>' value='<%if (csLineItem != null) out.print (csLineItem.getQtyShipped());%>'>
                        <input type="hidden" name='<%="previousQuantityShipped_"+i%>' value='<%if (csLineItem != null) out.print (csLineItem.getQtyShipped());%>'>
                        <input type="text" align='right' disabled name='<%="quantityShipped1_"+i%>' size="8" class='valuetxfield' value='<%if (csLineItem != null) out.print (StringUtils.formatUnits(csLineItem.getQtyShipped())); else out.print ("0");%>'>
                        </font>
                    </td>
                    <td width="2%" align="right" bgcolor='<%=bgColor%>'>
                    <%
                        //if ((!viewPackingSlip) || (((csLineItem != null) && (csLineItem.getStatus().equalsIgnoreCase (Constants.CUSTOMER_SHIPPING_STATUS_ISSED))) == false)) {
                        int csLineItemId = -1;
                        if (csLineItem != null) {
                            csLineItemId = csLineItem.getId();
                        }
                        String filedName = "quantityShipped_" + i;
                        String filedName1 = "quantityShipped1_" + i;
                    %>
                        
                        <chiptrack:lotQtyPull partNumber='<%=lineItem.getManufacturingPartNo()%>' lineItemId='<%=lineItem.getLineItemId()%>' csLineItemId='<%=csLineItemId%>' >
                            <A href="javascript:openInventory('<%=lineItem.getManufacturingPartNo()%>', '<%=lineItem.getLineItemId()%>', '<%=filedName%>', '<%=filedName1%>', '<%=csLineItemId%>', <%=(String) qtyToBeShippedList.get(i+"")%>);" onMouseOver="window.status='Click here to see the final finished goods and their locations';return true" onMouseOut="window.status='';return true">
                                <img border='0' height='12' width='16' src="<%=chipTracContext%>/jsp/includes/images/arrow.gif">
                            </A>
                        </chiptrack:lotQtyPull>

                        <chiptrack:lotQtyPull partNumber='<%=lineItem.getManufacturingPartNo()%>' lineItemId='<%=lineItem.getLineItemId()%>' csLineItemId='<%=csLineItemId%>' inverseFunctionality='true'>
                            <img border='0' alt="No inventory found for <%=lineItem.getManufacturingPartNo()%> " height='12' width='16' src="<%=chipTracContext%>/jsp/includes/images/cancel_icon.gif">
                        </chiptrack:lotQtyPull>

                    </td>
                    <!-- td width="8%" align="center" bgcolor='<%=bgColor%>'>
                        <font class="NArialL"><input type="text" name="balance" size="8" disabled class="disabledtxfield" value='<%if (csLineItem != null) out.print (requestedQuantity-csLineItem.getQtyShipped());%>'></font>
                    </td-->
                    <td width="8%" align="center" bgcolor='<%=bgColor%>'>
                        <font class="NArialL"><%if (csLineItem != null) out.print (csLineItem.getStatus()); else out.print("OPEN");%></font>
                    </td>
                </tr>
            <%
                }
            %>
	    <input type="hidden" name="lineItemCount" value='<%=size%>'>
            <tr><td colspan=9><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
	   </table>
	 </td></tr>
	 <tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
	 <tr><td colspan=6 align=center>


       

           <chiptrack:restrictedLink functionality='<%=Functionality.PACKING_SLIP%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:updatePackingSlip();' onmouseover="window.status='Click here to save packing slip';return true" onmouseout="window.status='';return true">
           <img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif"></chiptrack:restrictedLink>
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	   <a href="javascript:cancelAndGoBack();" onMouseOver="window.status='Click here to go back to packing slip menu';return true" onMouseOut="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif"></a>
      </td></tr>

    <tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=40></td></tr>

    </table>

</html:form>

<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=40 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</body>

</html:html>
